import { Menu } from "@/api/interface/systemMenu";
import { DRAGON_ADMIN } from "@/api/config/servicePort";
import http from "@/api";

// 获取菜单列表
export const getMenuListApi = (params?: Menu.MenuListReqParams) => {
  return http.get<Menu.MenuListRes[]>(DRAGON_ADMIN + `/api/system/menu/list`, params);
};

// 获取菜单详情
export const getMenuDetailApi = (menuId: number) => {
  return http.get<Menu.MenuDetailRes>(DRAGON_ADMIN + `/api/system/menu/detail`, { menuId: menuId });
};

// 新增菜单
export const addMenuApi = (params: Menu.MenuDetailRes) => {
  return http.post<void>(DRAGON_ADMIN + `/api/system/menu/add`, params);
};

// 编辑菜单
export const editMenuApi = (params: Menu.MenuDetailRes) => {
  return http.put<void>(DRAGON_ADMIN + `/api/system/menu/edit`, params);
};

// 删除菜单
export const deleteMenuApi = (menuId: number) => {
  return http.delete<void>(DRAGON_ADMIN + `/api/system/menu/delete`, { menuId: menuId });
};

// 更改菜单显示状态
export const changeMenuVisibleApi = (params: Menu.MenuChangeVisibleReq) => {
  return http.put<void>(DRAGON_ADMIN + `/api/system/menu/changeVisible`, params);
};

// 更改菜单状态
export const changeMenuStatusApi = (params: Menu.MenuChangeStatusReq) => {
  return http.put<void>(DRAGON_ADMIN + `/api/system/menu/changeStatus`, params);
};
